﻿using System;
using System.Data;
using System.Data.Common;
using System.Text;
using Besture.Common;
using Besture.Model;

namespace Besture.Dal
{
    public partial class HotelsCategoryDal : BaseDataAccess
    {

        /// <summary>
        /// 根据类型获取数据
        /// </summary>
        /// <param name="types"></param>
        /// <returns></returns>
        public DataTable GetDataTableByCategoryType(string types)
        {
            try
            {
                StringBuilder selectSql = new StringBuilder();
                selectSql.Append(string.Format(@"
                SELECT thc.*,dt.Name,thc1.CategoryName AS ParentName FROM dbo.TBHotelsCategory thc
                INNER JOIN dbo.TBDictionaryType dt ON dt.Code=thc.CategoryType AND dt.IsDeleted=0 AND thc.IsDeleted=0
                LEFT JOIN dbo.TBHotelsCategory thc1 ON thc1.ID=thc.ParentID AND thc1.IsDeleted=0 AND thc.IsDeleted=0
                WHERE 
                dt.Type=0 AND 
                thc.CategoryType IN ({0})
                ORDER BY thc.SortID DESC ", types));
                DbCommand ldcDBCommand = base.GetCommand(selectSql.ToString());
                DataTable dt = base.GetDataSet(ldcDBCommand).Tables[0];
                return dt;
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
    }
}

